<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="box">
        <button @click="++num">+</button>
        <input type="text" v-model="num">
        <button @click="sub">-</button>
    </div>

    <script>
        let vm = new Vue({
            el:"#box",
            
            data:{
                num:0,
            },
            
            methods:{
                sub(){
                    if(this.num<=1){
                        this.num=0;
                    }else{
                        this.num--;
                    }
                },
            }
        })
    </script>
</body>
</html>
